<!DOCTYPE html>












  


<html class="theme-next pisces use-motion" lang="zh-CN">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2"/>
<meta name="theme-color" content="#222">












<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />










  <meta name="baidu-site-verification" content="IiBpa7sUtv" />













<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=6.4.0" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=6.4.0">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=6.4.0">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=6.4.0">


  <link rel="mask-icon" href="/images/logo.svg?v=6.4.0" color="#222">









<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Pisces',
    version: '6.4.0',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: false,
    fastclick: false,
    lazyload: false,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>


  




  <meta name="description" content="sersync安装配置1，    安装配置rsync1见rsync部分">
<meta name="keywords" content="linux,sersync,实时同步">
<meta property="og:type" content="article">
<meta property="og:title" content="20，sersync安装配置">
<meta property="og:url" content="http://jonah222.gitee.io/2019/07/22/20，sersync安装配置/index.html">
<meta property="og:site_name" content="Z&#39;Blog">
<meta property="og:description" content="sersync安装配置1，    安装配置rsync1见rsync部分">
<meta property="og:locale" content="zh-CN">
<meta property="og:updated_time" content="2019-07-22T15:35:00.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="20，sersync安装配置">
<meta name="twitter:description" content="sersync安装配置1，    安装配置rsync1见rsync部分">






  <link rel="canonical" href="http://jonah222.gitee.io/2019/07/22/20，sersync安装配置/"/>



<script type="text/javascript" id="page.configurations">
  CONFIG.page = {
    sidebar: "",
  };
</script>

  <title>20，sersync安装配置 | Z'Blog</title>
  









  <noscript>
  <style type="text/css">
    .use-motion .motion-element,
    .use-motion .brand,
    .use-motion .menu-item,
    .sidebar-inner,
    .use-motion .post-block,
    .use-motion .pagination,
    .use-motion .comments,
    .use-motion .post-header,
    .use-motion .post-body,
    .use-motion .collection-title { opacity: initial; }

    .use-motion .logo,
    .use-motion .site-title,
    .use-motion .site-subtitle {
      opacity: initial;
      top: initial;
    }

    .use-motion {
      .logo-line-before i { left: initial; }
      .logo-line-after i { right: initial; }
    }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-CN">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Z'Blog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
    
      
        <p class="site-subtitle">愿我的每一道微风，吹散我们心中一切痛苦的记忆！</p>
      
    
  </div>

  <div class="site-nav-toggle">
    <button aria-label="切换导航栏">
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>



<nav class="site-nav">
  
    <ul id="menu" class="menu">
      
        
        
        
          
          <li class="menu-item menu-item-home">
    <a href="/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-home"></i> <br />首页</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-archives">
    <a href="/archives/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />归档</a>
  </li>

      
      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />搜索</a>
        </li>
      
    </ul>
  

  

  
    <div class="site-search">
      
  <div class="popup search-popup local-search-popup">
  <div class="local-search-header clearfix">
    <span class="search-icon">
      <i class="fa fa-search"></i>
    </span>
    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
    <div class="local-search-input-wrapper">
      <input autocomplete="off"
             placeholder="搜索..." spellcheck="false"
             type="text" id="local-search-input">
    </div>
  </div>
  <div id="local-search-result"></div>
</div>



    </div>
  
</nav>



  



</div>
    </header>

    


    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          
            

          
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://jonah222.gitee.io/2019/07/22/20，sersync安装配置/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Jonah">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Z'Blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">20，sersync安装配置
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">

            
            
            

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              

              
                
              

              <time title="创建时间：2019-07-22 23:35:00" itemprop="dateCreated datePublished" datetime="2019-07-22T23:35:00+08:00">2019-07-22</time>
            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/linux/" itemprop="url" rel="index"><span itemprop="name">linux</span></a></span>

                
                
              
            </span>
          

          
            
          

          
          
             <span id="/2019/07/22/20，sersync安装配置/" class="leancloud_visitors" data-flag-title="20，sersync安装配置">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               
                 <span class="post-meta-item-text">阅读次数：</span>
               
                 <span class="leancloud-visitors-count"></span>
             </span>
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h3 id="sersync安装配置"><a href="#sersync安装配置" class="headerlink" title="sersync安装配置"></a>sersync安装配置</h3><h4 id="1，-安装配置rsync"><a href="#1，-安装配置rsync" class="headerlink" title="1，    安装配置rsync"></a>1，    安装配置rsync</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">见rsync部分</span><br></pre></td></tr></table></figure>
<a id="more"></a>
<h4 id="2，-安装inotify"><a href="#2，-安装inotify" class="headerlink" title="2，    安装inotify"></a>2，    安装inotify</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#配置yum源</span></span><br><span class="line">mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak</span><br><span class="line">wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centsos-6.repo</span><br><span class="line"></span><br><span class="line">mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.bak</span><br><span class="line">mv /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.bak</span><br><span class="line">wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo</span><br><span class="line"></span><br><span class="line"><span class="comment">#安装inotify</span></span><br><span class="line">yum install inotify-tools –y</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">#/server/scrpts/inotify.sh脚本内容</span></span><br><span class="line"><span class="meta">#!/bin/bash</span></span><br><span class="line"><span class="comment">#desc:inotify实时同步</span></span><br><span class="line"><span class="comment">#author:z</span></span><br><span class="line"></span><br><span class="line">Path=/data</span><br><span class="line">Ip=172.16.1.41</span><br><span class="line"></span><br><span class="line">/usr/bin/inotifywait -mrq --format <span class="string">'%w%f'</span> -e close_write,delete <span class="variable">$Path</span> \</span><br><span class="line">|<span class="keyword">while</span> <span class="built_in">read</span> file</span><br><span class="line">  <span class="keyword">do</span></span><br><span class="line">  <span class="keyword">if</span> [ -f <span class="variable">$file</span> ];<span class="keyword">then</span></span><br><span class="line">    rsync -az <span class="variable">$file</span> --delete rsync_backup@<span class="variable">$Ip</span>::nfsbackup --password-file=/etc/rsync.password</span><br><span class="line">  <span class="keyword">else</span></span><br><span class="line">    <span class="built_in">cd</span> <span class="variable">$Path</span> &amp;&amp;\</span><br><span class="line">    rsync -az ./ --delete rsync_backup@<span class="variable">$Ip</span>::nfsbackup --password-file=/etc/rsync.password</span><br><span class="line">  <span class="keyword">fi</span></span><br><span class="line"><span class="keyword">done</span></span><br></pre></td></tr></table></figure>
<h4 id="3，-安装sersync"><a href="#3，-安装sersync" class="headerlink" title="3，    安装sersync"></a>3，    安装sersync</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#把准备好的sersync安装包上传到服务器上</span></span><br><span class="line"><span class="built_in">cd</span> /server/tools</span><br><span class="line">rz</span><br><span class="line">[root@nfs01 /server/tools ]<span class="comment"># ls</span></span><br><span class="line">sersync  sersync_bak  sersync.zip</span><br><span class="line"><span class="comment">#解压即可</span></span><br><span class="line">unzip sersync.zip </span><br><span class="line"><span class="comment">#添加 可执行权限</span></span><br><span class="line">chmod +x /application/sersync/sersync2</span><br><span class="line"><span class="comment">#创建软连接</span></span><br><span class="line">ln -s /application/sersync/sersync2 /usr/bin/sersync</span><br></pre></td></tr></table></figure>
<h4 id="4，-修改配置文件"><a href="#4，-修改配置文件" class="headerlink" title="4，    修改配置文件"></a>4，    修改配置文件</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br></pre></td><td class="code"><pre><span class="line">vim sersync/conf/confxml.xml</span><br><span class="line"></span><br><span class="line">&lt;?xml version=<span class="string">"1.0"</span> encoding=<span class="string">"ISO-8859-1"</span>?&gt;</span><br><span class="line">&lt;head version=<span class="string">"2.5"</span>&gt;</span><br><span class="line">  &lt;host hostip=<span class="string">"localhost"</span> port=<span class="string">"8008"</span>&gt;&lt;/host&gt;</span><br><span class="line">  &lt;debug start=<span class="string">"false"</span>/&gt;</span><br><span class="line">  &lt;fileSystem xfs=<span class="string">"false"</span>/&gt;</span><br><span class="line">  &lt;filter start=<span class="string">"false"</span>&gt;</span><br><span class="line">    &lt;exclude expression=<span class="string">"(.*)\.svn"</span>&gt;&lt;/exclude&gt;</span><br><span class="line">    &lt;exclude expression=<span class="string">"(.*)\.gz"</span>&gt;&lt;/exclude&gt;</span><br><span class="line">    &lt;exclude expression=<span class="string">"^info/*"</span>&gt;&lt;/exclude&gt;</span><br><span class="line">    &lt;exclude expression=<span class="string">"^static/*"</span>&gt;&lt;/exclude&gt;</span><br><span class="line">  &lt;/filter&gt;</span><br><span class="line">  &lt;inotify&gt;</span><br><span class="line">    &lt;delete start=<span class="string">"true"</span>/&gt;</span><br><span class="line">    &lt;createFolder start=<span class="string">"true"</span>/&gt;</span><br><span class="line">    &lt;createFile start=<span class="string">"false"</span>/&gt;</span><br><span class="line">    &lt;closeWrite start=<span class="string">"true"</span>/&gt;</span><br><span class="line">    &lt;moveFrom start=<span class="string">"true"</span>/&gt;</span><br><span class="line">    &lt;moveTo start=<span class="string">"true"</span>/&gt;</span><br><span class="line">    &lt;attrib start=<span class="string">"false"</span>/&gt;</span><br><span class="line">    &lt;modify start=<span class="string">"false"</span>/&gt;</span><br><span class="line">  &lt;/inotify&gt;</span><br><span class="line">  &lt;sersync&gt;</span><br><span class="line">&lt;localpath watch=<span class="string">"/data"</span>&gt;</span><br><span class="line">&lt;!--/data:nfs服务器共享的目录，即要被推送的目录--&gt;</span><br><span class="line">      &lt;remote ip=<span class="string">"172.16.1.41"</span> name=<span class="string">"nfsbackup"</span>/&gt;</span><br><span class="line">&lt;!—ip:备份服务器IP，name:rsync的模块名--&gt;</span><br><span class="line">      &lt;!--&lt;remote ip=<span class="string">"192.168.8.39"</span> name=<span class="string">"tongbu"</span>/&gt;--&gt;</span><br><span class="line">      &lt;!--&lt;remote ip=<span class="string">"192.168.8.40"</span> name=<span class="string">"tongbu"</span>/&gt;--&gt;</span><br><span class="line">    &lt;/localpath&gt;</span><br><span class="line">    &lt;rsync&gt;</span><br><span class="line">      &lt;commonParams params=<span class="string">"-az --delete"</span>/&gt;</span><br><span class="line">      &lt;!--rsync的参数--&gt;</span><br><span class="line">      &lt;auth start=<span class="string">"true"</span> users=<span class="string">"rsync_backup"</span> passwordfile=<span class="string">"/etc/rsync.password"</span>/&gt;</span><br><span class="line">&lt;!-- start=<span class="literal">true</span>：表示开启这个推送，users:rsync配置文件中的用户，passwordfile:rsync的密码文件--&gt;</span><br><span class="line">      &lt;userDefinedPort start=<span class="string">"false"</span> port=<span class="string">"874"</span>/&gt;</span><br><span class="line">      &lt;!-- port=874 --&gt;</span><br><span class="line">      &lt;timeout start=<span class="string">"true"</span> time=<span class="string">"100"</span>/&gt;</span><br><span class="line">      &lt;!-- timeout=100 --&gt;</span><br><span class="line">      &lt;ssh start=<span class="string">"false"</span>/&gt;</span><br><span class="line">    &lt;/rsync&gt;</span><br><span class="line">    &lt;failLog path=<span class="string">"/application/sersync/logs/rsync_fail_log.sh"</span> timeToExecute=<span class="string">"60"</span>/&gt;</span><br><span class="line">    &lt;!--default every 60mins execute once--&gt;</span><br><span class="line">    &lt;crontab start=<span class="string">"false"</span> schedule=<span class="string">"600"</span>&gt;</span><br><span class="line">      &lt;!--600mins--&gt;</span><br><span class="line">      &lt;crontabfilter start=<span class="string">"false"</span>&gt;</span><br><span class="line">        &lt;exclude expression=<span class="string">"*.php"</span>&gt;&lt;/exclude&gt;</span><br><span class="line">        &lt;exclude expression=<span class="string">"info/*"</span>&gt;&lt;/exclude&gt;</span><br><span class="line">      &lt;/crontabfilter&gt;</span><br><span class="line">    &lt;/crontab&gt;</span><br><span class="line">    &lt;plugin start=<span class="string">"false"</span> name=<span class="string">"command"</span>/&gt;</span><br><span class="line">  &lt;/sersync&gt;</span><br><span class="line">  &lt;plugin name=<span class="string">"command"</span>&gt;</span><br><span class="line">    &lt;param prefix=<span class="string">"/bin/sh"</span> suffix=<span class="string">""</span> ignoreError=<span class="string">"true"</span>/&gt;</span><br><span class="line">    &lt;!--prefix /opt/tongbu/mmm.sh suffix--&gt;</span><br><span class="line">    &lt;filter start=<span class="string">"false"</span>&gt;</span><br><span class="line">      &lt;include expression=<span class="string">"(.*)\.php"</span>/&gt;</span><br><span class="line">      &lt;include expression=<span class="string">"(.*)\.sh"</span>/&gt;</span><br><span class="line">    &lt;/filter&gt;</span><br><span class="line">  &lt;/plugin&gt;</span><br><span class="line">  &lt;plugin name=<span class="string">"socket"</span>&gt;</span><br><span class="line">    &lt;localpath watch=<span class="string">"/opt/tongbu"</span>&gt;</span><br><span class="line">      &lt;deshost ip=<span class="string">"192.168.138.20"</span> port=<span class="string">"8009"</span>/&gt;</span><br><span class="line">    &lt;/localpath&gt;</span><br><span class="line">  &lt;/plugin&gt;</span><br><span class="line">  &lt;plugin name=<span class="string">"refreshCDN"</span>&gt;</span><br><span class="line">    &lt;localpath watch=<span class="string">"/data0/htdocs/cms.xoyo.com/site/"</span>&gt;</span><br><span class="line">      &lt;cdninfo domainname=<span class="string">"ccms.chinacache.com"</span> port=<span class="string">"80"</span> username=<span class="string">"xxxx"</span> passwd=<span class="string">"xxxx"</span>/&gt;</span><br><span class="line">      &lt;sendurl base=<span class="string">"http://pic.xoyo.com/cms"</span>/&gt;</span><br><span class="line">      &lt;regexurl regex=<span class="string">"false"</span> match=<span class="string">"cms.xoyo.com/site([/a-zA-Z0-9]*).xoyo.com/images"</span>/&gt;</span><br><span class="line">    &lt;/localpath&gt;</span><br><span class="line">  &lt;/plugin&gt;</span><br><span class="line">&lt;/head&gt;</span><br></pre></td></tr></table></figure>
<h4 id="5，-启动sersync"><a href="#5，-启动sersync" class="headerlink" title="5，    启动sersync"></a>5，    启动sersync</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br></pre></td><td class="code"><pre><span class="line">[root@nfs01 /application]<span class="comment">#  /application/sersync/sersync2 -d -r -n 8 -o /application/sersync/conf/confxml.xml</span></span><br><span class="line"><span class="built_in">set</span> the system param</span><br><span class="line">execute：<span class="built_in">echo</span> 50000000 &gt; /proc/sys/fs/inotify/max_user_watches</span><br><span class="line">execute：<span class="built_in">echo</span> 327679 &gt; /proc/sys/fs/inotify/max_queued_events</span><br><span class="line">parse the <span class="built_in">command</span> param</span><br><span class="line">option: -d      run as a daemon</span><br><span class="line">option: -r      rsync all the <span class="built_in">local</span> files to the remote servers before the sersync work</span><br><span class="line">option: -n      thread num is：  8</span><br><span class="line">option: -o      config xml name：  /application/sersync/conf/confxml.xml</span><br><span class="line">parse xml config file</span><br><span class="line">host ip : localhost     host port: 8008</span><br><span class="line">daemon start，sersync run behind the console </span><br><span class="line">use rsync password-file :</span><br><span class="line">user is rsync_backup</span><br><span class="line">passwordfile is         /etc/rsync.password</span><br><span class="line">config xml parse success</span><br><span class="line">please <span class="built_in">set</span> /etc/rsyncd.conf max connections=0 Manually</span><br><span class="line">sersync working thread 10  = 1(primary thread) + 1(fail retry thread) + 8(daemon sub threads) </span><br><span class="line">Max threads numbers is: 18 = 10(Thread pool nums) + 8(Sub threads)</span><br><span class="line">please according your cpu ，use -n param to adjust the cpu rate</span><br><span class="line">------------------------------------------</span><br><span class="line">rsync the directory recursivly to the remote servers once</span><br><span class="line">working please <span class="built_in">wait</span>...</span><br><span class="line">execute <span class="built_in">command</span>: <span class="built_in">cd</span> /data &amp;&amp; rsync -az -R --delete ./  --timeout=100 rsync_backup@172.16.1.41::nfsbackup --password-file=/etc/rsync.password &gt;/dev/null 2&gt;&amp;1 </span><br><span class="line">run the sersync: </span><br><span class="line">watch path is: /data</span><br><span class="line">[root@nfs01 /application]<span class="comment">#ps -ef|grep sersync</span></span><br><span class="line">root       2177      1  0 10:16 ?        00:00:00 /application/sersync/sersync2 -d -r -n 8 -o /application/sersync/conf/confxml.xml</span><br><span class="line">root       2191   1826  0 10:17 pts/0    00:00:00 grep --color=auto sersync2</span><br></pre></td></tr></table></figure>
<h4 id="6，添加到-etc-rc-local，开机自启动"><a href="#6，添加到-etc-rc-local，开机自启动" class="headerlink" title="6，添加到/etc/rc.local，开机自启动"></a>6，添加到/etc/rc.local，开机自启动</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">echo</span> <span class="string">"#sersync 开机自启动"</span> &gt;&gt;/etc/rc.local</span><br><span class="line"><span class="comment">#echo "/application/sersync/sersync2 -d -r -n 8 -o /application/sersync/conf/confxml.xml" &gt;&gt;/etc/rc.local</span></span><br><span class="line"></span><br><span class="line"><span class="built_in">echo</span> <span class="string">"/usr/bin/sersync -d -r -n 8 -o /application/sersync/conf/confxml.xml"</span> &gt;&gt;/etc/rc.local</span><br><span class="line"></span><br><span class="line">tail /etc/rc.local</span><br></pre></td></tr></table></figure>

      
    </div>

    

    
    
    

    

    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/linux/" rel="tag"># linux</a>
          
            <a href="/tags/sersync/" rel="tag"># sersync</a>
          
            <a href="/tags/实时同步/" rel="tag"># 实时同步</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2019/07/21/19，全网备份项目/" rel="next" title="19，全网备份项目">
                <i class="fa fa-chevron-left"></i> 19，全网备份项目
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2019/07/23/21，定时任务的简单说明/" rel="prev" title="21，定时任务的简单说明">
                21，定时任务的简单说明 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>


  </div>


          </div>
          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">Jonah</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          
            <nav class="site-state motion-element">
              
                <div class="site-state-item site-state-posts">
                
                  <a href="/archives/">
                
                    <span class="site-state-item-count">23</span>
                    <span class="site-state-item-name">日志</span>
                  </a>
                </div>
              

              
                
                
                <div class="site-state-item site-state-categories">
                  
                    
                    
                      
                    
                      
                    
                      
                    
                      
                    
                    <span class="site-state-item-count">4</span>
                    <span class="site-state-item-name">分类</span>
                  
                </div>
              

              
                
                
                <div class="site-state-item site-state-tags">
                  
                    
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                    <span class="site-state-item-count">26</span>
                    <span class="site-state-item-name">标签</span>
                  
                </div>
              
            </nav>
          

          

          

          
          

          
          

          
            
          
          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#sersync安装配置"><span class="nav-number">1.</span> <span class="nav-text">sersync安装配置</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#1，-安装配置rsync"><span class="nav-number">1.1.</span> <span class="nav-text">1，    安装配置rsync</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#2，-安装inotify"><span class="nav-number">1.2.</span> <span class="nav-text">2，    安装inotify</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#3，-安装sersync"><span class="nav-number">1.3.</span> <span class="nav-text">3，    安装sersync</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#4，-修改配置文件"><span class="nav-number">1.4.</span> <span class="nav-text">4，    修改配置文件</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#5，-启动sersync"><span class="nav-number">1.5.</span> <span class="nav-text">5，    启动sersync</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#6，添加到-etc-rc-local，开机自启动"><span class="nav-number">1.6.</span> <span class="nav-text">6，添加到/etc/rc.local，开机自启动</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2019</span>
  <span class="with-love" id="animate">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Jonah</span>

  

  
</div>




  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动 v3.7.1</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 – <a class="theme-link" target="_blank" href="https://theme-next.org">NexT.Pisces</a> v6.4.0</div>




<!--jonah222.github.io百度统计-->
<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?727ba39b884a8a685b4f7be701da0cd5";
  var s = document.getElementsByTagName("script")[0];
  s.parentNode.insertBefore(hm, s);
})();
</script>

<!--jonah222.gitee.io百度统计-->
<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?86403053aaf1e2794b12284e606e7989";
  var s = document.getElementsByTagName("script")[0];
  s.parentNode.insertBefore(hm, s);
})();
</script>

        
<div class="busuanzi-count">
  <script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="site-uv" title="总访客量">
      <i class="fa fa-user"></i>
      总访问人数：
      <span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
    </span>
  

  
    <span class="site-pv" title="总访问量">
      <i class="fa fa-eye"></i>
      总访问次数：
      <span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
    </span>
  
</div>









        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    
	
    

    
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>


























  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=6.4.0"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=6.4.0"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=6.4.0"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=6.4.0"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=6.4.0"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=6.4.0"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=6.4.0"></script>



  



  










  

  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    var isXml = true;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length === 0) {
      search_path = "search.xml";
    } else if (/json$/i.test(search_path)) {
      isXml = false;
    }
    var path = "/" + search_path;
    // monitor main search box;

    var onPopupClose = function (e) {
      $('.popup').hide();
      $('#local-search-input').val('');
      $('.search-result-list').remove();
      $('#no-result').remove();
      $(".local-search-pop-overlay").remove();
      $('body').css('overflow', '');
    }

    function proceedsearch() {
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay"></div>')
        .css('overflow', 'hidden');
      $('.search-popup-overlay').click(onPopupClose);
      $('.popup').toggle();
      var $localSearchInput = $('#local-search-input');
      $localSearchInput.attr("autocapitalize", "none");
      $localSearchInput.attr("autocorrect", "off");
      $localSearchInput.focus();
    }

    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';

      // start loading animation
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay">' +
          '<div id="search-loading-icon">' +
          '<i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>' +
          '</div>' +
          '</div>')
        .css('overflow', 'hidden');
      $("#search-loading-icon").css('margin', '20% auto 0 auto').css('text-align', 'center');

      

      $.ajax({
        url: path,
        dataType: isXml ? "xml" : "json",
        async: true,
        success: function(res) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = isXml ? $("entry", res).map(function() {
            return {
              title: $("title", this).text(),
              content: $("content",this).text(),
              url: $("url" , this).text()
            };
          }).get() : res;
          var input = document.getElementById(search_id);
          var resultContent = document.getElementById(content_id);
          var inputEventFunction = function() {
            var searchText = input.value.trim().toLowerCase();
            var keywords = searchText.split(/[\s\-]+/);
            if (keywords.length > 1) {
              keywords.push(searchText);
            }
            var resultItems = [];
            if (searchText.length > 0) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var hitCount = 0;
                var searchTextCount = 0;
                var title = data.title.trim();
                var titleInLowerCase = title.toLowerCase();
                var content = data.content.trim().replace(/<[^>]+>/g,"");
                
                var contentInLowerCase = content.toLowerCase();
                var articleUrl = decodeURIComponent(data.url);
                var indexOfTitle = [];
                var indexOfContent = [];
                // only match articles with not empty titles
                if(title != '') {
                  keywords.forEach(function(keyword) {
                    function getIndexByWord(word, text, caseSensitive) {
                      var wordLen = word.length;
                      if (wordLen === 0) {
                        return [];
                      }
                      var startPosition = 0, position = [], index = [];
                      if (!caseSensitive) {
                        text = text.toLowerCase();
                        word = word.toLowerCase();
                      }
                      while ((position = text.indexOf(word, startPosition)) > -1) {
                        index.push({position: position, word: word});
                        startPosition = position + wordLen;
                      }
                      return index;
                    }

                    indexOfTitle = indexOfTitle.concat(getIndexByWord(keyword, titleInLowerCase, false));
                    indexOfContent = indexOfContent.concat(getIndexByWord(keyword, contentInLowerCase, false));
                  });
                  if (indexOfTitle.length > 0 || indexOfContent.length > 0) {
                    isMatch = true;
                    hitCount = indexOfTitle.length + indexOfContent.length;
                  }
                }

                // show search results

                if (isMatch) {
                  // sort index by position of keyword

                  [indexOfTitle, indexOfContent].forEach(function (index) {
                    index.sort(function (itemLeft, itemRight) {
                      if (itemRight.position !== itemLeft.position) {
                        return itemRight.position - itemLeft.position;
                      } else {
                        return itemLeft.word.length - itemRight.word.length;
                      }
                    });
                  });

                  // merge hits into slices

                  function mergeIntoSlice(text, start, end, index) {
                    var item = index[index.length - 1];
                    var position = item.position;
                    var word = item.word;
                    var hits = [];
                    var searchTextCountInSlice = 0;
                    while (position + word.length <= end && index.length != 0) {
                      if (word === searchText) {
                        searchTextCountInSlice++;
                      }
                      hits.push({position: position, length: word.length});
                      var wordEnd = position + word.length;

                      // move to next position of hit

                      index.pop();
                      while (index.length != 0) {
                        item = index[index.length - 1];
                        position = item.position;
                        word = item.word;
                        if (wordEnd > position) {
                          index.pop();
                        } else {
                          break;
                        }
                      }
                    }
                    searchTextCount += searchTextCountInSlice;
                    return {
                      hits: hits,
                      start: start,
                      end: end,
                      searchTextCount: searchTextCountInSlice
                    };
                  }

                  var slicesOfTitle = [];
                  if (indexOfTitle.length != 0) {
                    slicesOfTitle.push(mergeIntoSlice(title, 0, title.length, indexOfTitle));
                  }

                  var slicesOfContent = [];
                  while (indexOfContent.length != 0) {
                    var item = indexOfContent[indexOfContent.length - 1];
                    var position = item.position;
                    var word = item.word;
                    // cut out 100 characters
                    var start = position - 20;
                    var end = position + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if (end < position + word.length) {
                      end = position + word.length;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    slicesOfContent.push(mergeIntoSlice(content, start, end, indexOfContent));
                  }

                  // sort slices in content by search text's count and hits' count

                  slicesOfContent.sort(function (sliceLeft, sliceRight) {
                    if (sliceLeft.searchTextCount !== sliceRight.searchTextCount) {
                      return sliceRight.searchTextCount - sliceLeft.searchTextCount;
                    } else if (sliceLeft.hits.length !== sliceRight.hits.length) {
                      return sliceRight.hits.length - sliceLeft.hits.length;
                    } else {
                      return sliceLeft.start - sliceRight.start;
                    }
                  });

                  // select top N slices in content

                  var upperBound = parseInt('1');
                  if (upperBound >= 0) {
                    slicesOfContent = slicesOfContent.slice(0, upperBound);
                  }

                  // highlight title and content

                  function highlightKeyword(text, slice) {
                    var result = '';
                    var prevEnd = slice.start;
                    slice.hits.forEach(function (hit) {
                      result += text.substring(prevEnd, hit.position);
                      var end = hit.position + hit.length;
                      result += '<b class="search-keyword">' + text.substring(hit.position, end) + '</b>';
                      prevEnd = end;
                    });
                    result += text.substring(prevEnd, slice.end);
                    return result;
                  }

                  var resultItem = '';

                  if (slicesOfTitle.length != 0) {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + highlightKeyword(title, slicesOfTitle[0]) + "</a>";
                  } else {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + title + "</a>";
                  }

                  slicesOfContent.forEach(function (slice) {
                    resultItem += "<a href='" + articleUrl + "'>" +
                      "<p class=\"search-result\">" + highlightKeyword(content, slice) +
                      "...</p>" + "</a>";
                  });

                  resultItem += "</li>";
                  resultItems.push({
                    item: resultItem,
                    searchTextCount: searchTextCount,
                    hitCount: hitCount,
                    id: resultItems.length
                  });
                }
              })
            };
            if (keywords.length === 1 && keywords[0] === "") {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>'
            } else if (resultItems.length === 0) {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>'
            } else {
              resultItems.sort(function (resultLeft, resultRight) {
                if (resultLeft.searchTextCount !== resultRight.searchTextCount) {
                  return resultRight.searchTextCount - resultLeft.searchTextCount;
                } else if (resultLeft.hitCount !== resultRight.hitCount) {
                  return resultRight.hitCount - resultLeft.hitCount;
                } else {
                  return resultRight.id - resultLeft.id;
                }
              });
              var searchResultList = '<ul class=\"search-result-list\">';
              resultItems.forEach(function (result) {
                searchResultList += result.item;
              })
              searchResultList += "</ul>";
              resultContent.innerHTML = searchResultList;
            }
          }

          if ('auto' === 'auto') {
            input.addEventListener('input', inputEventFunction);
          } else {
            $('.search-icon').click(inputEventFunction);
            input.addEventListener('keypress', function (event) {
              if (event.keyCode === 13) {
                inputEventFunction();
              }
            });
          }

          // remove loading animation
          $(".local-search-pop-overlay").remove();
          $('body').css('overflow', '');

          proceedsearch();
        }
      });
    }

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched === false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(onPopupClose);
    $('.popup').click(function(e){
      e.stopPropagation();
    });
    $(document).on('keyup', function (event) {
      var shouldDismissSearchPopup = event.which === 27 &&
        $('.search-popup').is(':visible');
      if (shouldDismissSearchPopup) {
        onPopupClose();
      }
    });
  </script>





  

  
  <script>
    
    function addCount(Counter) {
      var $visitors = $(".leancloud_visitors");
      var url = $visitors.attr('id').trim();
      var title = $visitors.attr('data-flag-title').trim();

      Counter('get', '/classes/Counter', { where: JSON.stringify({ url }) })
        .done(function ({ results }) {
          if (results.length > 0) {
            var counter = results[0];
            
              var $element = $(document.getElementById(url));
              $element.find('.leancloud-visitors-count').text(counter.time + 1);
            
            Counter('put', `/classes/Counter/${counter.objectId}`, JSON.stringify({ time: { "__op":"Increment", "amount":1 } }))
            
            .fail(function ({ responseJSON }) {
                console.log('Failed to save Visitor num, with error message: ' + responseJSON.error);
            })
          } else {
            
              var $element = $(document.getElementById(url));
              $element.find('.leancloud-visitors-count').text('Counter not initialized! See more at console err msg.');
              console.error('ATTENTION! LeanCloud counter has security bug, see here how to solve it: https://github.com/theme-next/hexo-leancloud-counter-security. \n But you also can use LeanCloud without security, by set \'security\' option to \'false\'.');
            
          }
        })
      .fail(function ({ responseJSON }) {
        console.log('LeanCloud Counter Error:' + responseJSON.code + " " + responseJSON.error);
      });
    }
    

    $(function() {
      $.get('https://app-router.leancloud.cn/2/route?appId=' + "Xa7CNWOfRPoEyhDWE68ETq83-gzGzoHsz")
        .done(function ({ api_server }) {
          var Counter = function (method, url, data) {
            return $.ajax({
              method: method,
              url: `https://${api_server}/1.1${url}`,
              headers: {
                'X-LC-Id': "Xa7CNWOfRPoEyhDWE68ETq83-gzGzoHsz",
                'X-LC-Key': "gq8hKrWjc5z7sFCmlFvrDOFk",
                'Content-Type': 'application/json',
              },
              data: data,
            });
          };
          
          addCount(Counter);
          
        })
    });
  </script>



  

  

  

  
  

  

  

  

  

  

</body>
</html>
